package com.cmcm.network

import com.android.build.gradle.AppExtension;
import com.android.build.gradle.AppPlugin;

import org.gradle.api.Plugin;
import org.gradle.api.Project
import org.gradle.api.tasks.compile.JavaCompile;

/**
 * Created by gezihua on 17-1-4.
 */

public class NetworkAspectPlaugin implements Plugin<Project> {
    private String mClassPath;

    @Override
    public void apply(Project project) {
        boolean isApp = project.getPlugins().hasPlugin(AppPlugin.class);
        if (!isApp){
           return;
        }
        def android = project.extensions.getByType(AppExtension.class);
        def variants = android.applicationVariants;
        JavaCompile javaCompile;

        project.afterEvaluate{
            variants.all { variant ->
                javaCompile = variant.javaCompile;
                project.logger.error("start to hoooooooooooook");
                 javaCompile = variant.javaCompile;
                mClassPath = javaCompile.classpath.asPath


            }

        }
        NetTrans netTrans = new NetTrans(project);
        netTrans.setClassPath("/home/gezihua/code/aop/Aop/plaugin/aspectjrt.jar");
        project.logger.error(""+(mClassPath));
        android.registerTransform(netTrans);
    }
}
